package com.hermes.action.json;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.hermes.biz.common.model.item.ItemDO;
import com.hermes.biz.common.model.result.AsynResultDO;
import com.hermes.biz.service.item.ItemService;
import com.hermes.common.action.AsynBaseAction;
import com.hermes.common.util.ParameterParserUtil;

public class AsynGetSameSrcItems extends AsynBaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2595566995217130413L;

	private Logger  log = Logger.getLogger(AsynGetItemToHtml.class);
	
	private ItemService itemService;
	
	private List<AsynResultDO>  resultList;

	private String content;
	
	private String itemTitle;
	
	private String itemPic;
	
	public String execute() {
		

		String page = ParameterParserUtil.getParameter("sourceId");
		
		List<ItemDO> itemResult = itemService.getAllItemList(1,9);
		
		int count=7;
		
		log.error("ȡ���Ĵ�С��"+itemResult.size());
		
		if (itemResult.size()>0){
			resultList = new ArrayList<AsynResultDO>();
			for(ItemDO item: itemResult){
				if(count<0){
					break;
				}
				count--;
				AsynResultDO temp = new AsynResultDO();
				temp.setItemPic(item.getItemPicUrl());
				temp.setItemTitle(item.getItemTitle());
				temp.setTagId(item.getTagId());
				temp.setItemId(item.getItemId());
				resultList.add(temp);
			}
			
			log.error("��vm�еĴ�С��"+resultList.size());
			
			setContent(String.valueOf(resultList.size()));

			return SUCCESS;
		}
			return ERROR;
}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	public void setItemService(ItemService itemService) {
		this.itemService = itemService;
	}

	public String getItemTitle() {
		return itemTitle;
	}

	public void setItemTitle(String itemTitle) {
		this.itemTitle = itemTitle;
	}

	public String getItemPic() {
		return itemPic;
	}

	public void setItemPic(String itemPic) {
		this.itemPic = itemPic;
	}

	public List<AsynResultDO> getResultList() {
		return resultList;
	}

	public void setResultList(List<AsynResultDO> resultList) {
		this.resultList = resultList;
	}
	
}
